package com.yyjj.my.fragment;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aries.ui.view.title.TitleBarView;
import com.avos.avoscloud.AVUser;
import com.vise.xsnow.event.IEvent;
import com.vise.xsnow.event.Subscribe;
import com.yyjj.my.R;

import tech.com.commoncore.base.BaseTitleFragment;

public class MineFragment extends BaseTitleFragment {
    TextView tvName;
    TextView tv_signature;
    ImageView imgUser;
    LinearLayout llUser;
    LinearLayout llCollection;
    LinearLayout llAttention;
    LinearLayout llSettings;
    LinearLayout llFeedback;
    LinearLayout llNews;
    LinearLayout llLogin;

    AVUser mUser;
    public static MineFragment newInstance() {
        Bundle args = new Bundle();
        MineFragment fragment = new MineFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText("我的").setLeftTextDrawable(null);
    }

    @Override
    public int getContentLayout() {
        return R.layout.my_fragmnet_mine;
    }

    @Override
    public void initView(Bundle savedInstanceState) {


         tvName = mContext.findViewById(R.id.tv_name);
         tv_signature = mContext.findViewById(R.id.tv_signature);
         imgUser = mContext.findViewById(R.id.img_user);
         llUser = mContext.findViewById(R.id.ll_user);
         llCollection = mContext.findViewById(R.id.ll_collection);
         llAttention = mContext.findViewById(R.id.ll_attention);
         llSettings = mContext.findViewById(R.id.ll_settings);
         llFeedback = mContext.findViewById(R.id.ll_feedback);
         llNews = mContext.findViewById(R.id.tv_news);
         llLogin = mContext.findViewById(R.id.ll_login);

        initPageShow();
    }
    private void initPageShow(){
//        if(AVUser.getCurrentUser() == null){  //未登录
//            GlideManager.loadCircleImg(R.mipmap.ic_default_head,imgUser);
//            tvName.setText("登录/注册");
//            tv_signature.setText("这家伙很懒,什么也没留下.");
//            imgUser.setOnClickListener(new OnNoDoubleClickListener() {
//                @Override
//                public void onNoDoubleClick(View v) {
//                    ARouter.getInstance().build("/login/login").navigation();
//                }
//            });
//
//        }else{
//            GlideManager.loadCircleImg(AVUser.getCurrentUser().getString(AVDbManager.USER_HEAD_ICON),imgUser,R.mipmap.ic_default_head);
//            tvName.setText(AVUser.getCurrentUser().getString(AVDbManager.USER_NICKE_NAME));
//            tv_signature.setText("这家伙很懒,什么也没留下.");
//            imgUser.setOnClickListener(new OnNoDoubleClickListener() {
//                @Override
//                public void onNoDoubleClick(View v) {
//                    if(AVUser.getCurrentUser() == null){
//                        ARouter.getInstance().build("/login/login").navigation();
//                    }else{
//                        FastUtil.startActivity(mContext,SettingActivity.class);
//                    }
//                }
//            });
//        }
    }

    @Subscribe
    public void update(IEvent event){
        initPageShow();
    }
    @Override
    public boolean isRegisterEvent() {
        return true;
    }
}
